import { PORT1, MYPORT1 } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 工单管理模块
 */

// 获取工单看板数据
export const getTicketDashBoard = params => {
  return http.get(MYPORT1 + `/v2/tickets`, params);
};
// 获取编号
export const getCode = params => {
  return http.get(MYPORT1 + `/v2/ticket/generate_unique_code`, params);
};
// 修改工单
export const editTicket = params => {
  return http.put(MYPORT1 + `/v2/tickets/${params.id}`, params);
};
// 删除工单
export const deleteTicket = params => {
  return http.delete(MYPORT1 + `/v2/tickets/${params.id}`, {});
};
// 取消工单
export const cancelTicket = params => {
  return http.put(MYPORT1 + `/v2/tickets/${params.id}/cancel`, {});
};
// 审核工单
export const auditTicket = params => {
  return http.put(MYPORT1 + `/v2/tickets/${params.id}/audit`, { audit: params.audit });
};
// 创建工单
export const addTicket = params => {
  return http.post(MYPORT1 + `/v2/tickets`, params);
};

//我的工单列表
export const getTicketMyList = params => {
  return http.get(MYPORT1 + `/v2/query`, params);
};

//工单看板列表
export const getTicketRankBoard = params => {
  return http.get(MYPORT1 + `/v2/tickets/performers/leaderboard`, params);
};

//填写客户收货单号，状态由创建工单变为客户代收。customer_receipt_tracking
export const customerWaitingCollected = params => {
  return http.put(MYPORT1 + `/v2/tickets/${params.id}/customer-waiting-collected`, params);
};
//填写单户收货单号，状态由客户代收变为回收途中 customer_send_tracking
export const wayToRecovery = params => {
  return http.put(MYPORT1 + `/v2/tickets/${params.id}/way-to-recovery`, params);
};
